package com.seal.commons.infrastructure.facade.distributed.lock.annotation;

import java.lang.annotation.*;

/**
 * ClassName:DistributeLock <br/>
 * Date:     2019-04-15 15:06 <br/>
 *
 * @author yong.huang
 * @see
 * @since JDK 1.8
 */
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface DistributeLock {

    /** 锁的资源，redis的key*/
    String value() default "default_redis_lock";

    /** 持锁时间,单位毫秒*/
    long keepMills() default 30000;

    /** 当获取失败时候动作*/
    LockFailAction action() default LockFailAction.CONTINUE;

    LockType type() default  LockType.REDIS;

    enum LockFailAction{
        /** 放弃 */
        GIVEUP,
        /** 继续 */
        CONTINUE;
    }

    enum LockType{

        REDIS,

        ZOOKPEER;
    }

    /** 重试的间隔时间,设置GIVEUP忽略此项*/
    long sleepMills() default 200;

    /** 重试次数*/
    int retryTimes() default 5;

}
